<template>
  <div class="tab-bar-item" @click="ItemClick">
    <div v-if="!isActive">
      <slot name="item-icon"></slot>
    </div>
    <div v-else>
      <slot name="item-icon-active"></slot>
    </div>
    <div  :style="activeStyle">
      <slot name="item-text"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "TabBarItem",
  props:{
      path: String,
      activeColor:{
        type: String,
        default: 'blue'
      }
  },
  data() {
    return {
    };
  },
  methods:{
    ItemClick(){
     this.$router.replace(this.path);
    }
  },
  computed:{
    isActive(){
      return  this.$route.path === this.path? true: false;
    },
    activeStyle(){
      return this.isActive? {color: this.activeColor}: '';
    }
  }
};
</script>

<style>
.tab-bar-item {
  flex: 1;
  height: 49px;
  text-align: center;
  margin-top: 3px;
  font-size: 16px;
}
.tab-bar-item img {
  width: 24px;
  height: 24px;
  vertical-align: middle;
  margin-bottom: 3px;
}
.activeText {
	color: #1296db;
}
</style>